<!doctype html>
<!--
Copyright (c) 2012 Sean Connelly

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<html lang="en">
<head>
	<title>Rho Language Specification (MYTODO: version)</title>
	<style>
	body {
		font-family: sans-serif;
		font-size: 90%;
		background-color: #f7f7f7;
		color: #222;
		margin: 0;
		padding: 0;
	}
	h1 {
		margin: 1.2em 0 0 0;
	}
	h2 {
		margin: 1.2em 0 0 0;
		border-bottom: 1px solid #999;
	}
	h3 {
		margin: 1.2em 0 0 0;
		border-bottom: 1px dotted #aaa;
	}
	h4 {
		margin: 1.2em 0 0 0;
	}
	p {
		margin: 0.5em 0 1em 0;
	}
	a {
		color: #00f;
		text-decoration: none;
	}
	a:visited {
		color: #70a;
	}
	a:hover, a:active {
		text-decoration: underline;
	}
	a:active {
		color: #0b0;
	}
	a[href^="http://"],
	a[href^="https://"],
	a[href^="ftp://"] {
		background: url("") no-repeat scroll right center transparent;
		padding-right: 13px;
		/* thank you, Wikipedia */
	}
	a.nl {
		color: #88f;
		font-weight: normal;
		text-decoration: underline;
		float: right;
		font-style: italic;
		font-size: 11pt;
		visibility: hidden;
	}
	h1:hover>a.nl,
	h2:hover>a.nl,
	h3:hover>a.nl,
	h4:hover>a.nl,
	h5:hover>a.nl,
	h6:hover>a.nl {
		visibility: visible;
	}
	a.cc {
		font-family: serif;
		color: #007a5c;
		text-decoration: underline;
		border-bottom: 1px solid #007a5c;
	}
	a.cc:hover, a:active {
		color: #0a4;
		border-bottom-color: #0a4;
	}
	svg {
		margin: 0 1em;
		padding: 0;
	}
	table {
		border: 1px solid #222;
		margin: 1em;
		padding: 0;
	}
	table>thead>tr>th {
		background-color: #339;
		color: #f7f7ff;
		font-weight: bold;
		text-align: left;
		border-right: 1px solid #224;
		border-bottom: 1px solid #224;
		padding: 3px;
		margin: 0;
		vertical-align: top;
	}
	table>tbody>tr>td {
		background-color: #fff;
		border-right: 1px solid #aaa;
		border-bottom: 1px solid #aaa;
		padding: 3px;
		margin: 0;
		vertical-align: top;
	}
	table>tbody>tr:nth-child(2n)>td {
		background-color: #ddf;
	}
	table.tblClear, table.tblClearMerge {
		border: none;
		margin: 0;
		padding: 0;
	}
	table.tblClear>tbody>tr>td, table.tblClearMerge>tbody>tr>td {
		margin: 0;
		padding: 0;
		border: none;
		background-color: transparent;
	}
	table.tblClearMerge {
		border: 1px solid #000;
	}
	table.tblClearMerge>tbody>tr>td>table {
		margin: 0;
		border: none;
	}
	table.tblClearMerge>tbody>tr>td>table>tbody>tr>td {
		white-space: nowrap;
	}
	code {
		background-color: #d4d4d4;
		color: #000;
		font-family: monospace;
		font-size: 12pt;
	}
	code em {
		color: #666;
	}
	p.toplink {
		text-align: right;
		font-style: italic;
		font-size: 9pt;
	}
	#mainwrap {
		padding: 1em;
	}
	#title {
		text-align: center;
		margin: 0 0 2em 0;
	}
	#title h1 {
		margin: 0;
	}
	#toc {
		border: 1px solid #55d;
		background-color: #eef;
		padding: 1em;
		float: left;
	}
	#toc h2 {
		margin-top: 0.2em;
		border-bottom-color: #aaf;
	}
	#toc h3 {
		margin: 0;
		border-bottom-color: #aaf;
	}
	#toc ol {
		margin-bottom: 0.6em;
	}
	#footer {
		background-color: #222;
		color: #f7f7f7;
		border-top: 1px solid #000;
		text-align: right;
		padding: 1em;
	}
	#footer a {
		color: #ff0;
		background: none;
		padding: 0;
	}
	</style>
</head>
<body>
<a name="top"></a>
<div id="mainwrap">
	<div id="title">
		<h1>Rho Language Specification</h1>
		<p>
			Version: MYTODO: release version here<br />
			Released: MYTODO: date of release here<br />
			Copyright &copy; 2012 Sean Connelly &ndash; <a href="#license">License &raquo;</a>
		</p>
	</div>
	<div id="toc">
		<h2>Table of Contents</h2>
		<ol>
			<li><a href="#intro">Introduction</a><ol>
				<li><a href="#license">License</a></li>
				<li><a href="#conventions">Document Conventions</a></li>
				<li><a href="#releases">Release Structure</a></li>
			</ol></li>
			<li><a href="#source">Source File Format</a><ol>
				<li><a href="#whitespace">Whitespace</a></li>
				<li><a href="#versiontag">Version Tag</a></li>
			</ol></li>
			<li><a href="#lexer">Lexer</a><ol>
				<li><a href="#charcl">Character Classes</a></li>
				<li><a href="#keydents">Keydentifiers</a></li>
				<li><a href="#keywords">Keywords</a></li>
				<li><a href="#idents">Identifiers</a></li>
				<li><a href="#specials">Special Sequences</a></li>
				<li><a href="#numbers">Numbers</a></li>
				<li><a href="#ratiolit">Ratio Literals</a></li>
				<li><a href="#stringfmt">String Formats</a></li>
			</ol></li>
		</ol>
	</div>
	<div style="clear: both;"></div>

	<h2><a name="intro"></a>Introduction
		<a href="#intro" title="Link to this section" class="nl">link</a></h2>
	<p>
		Rho is designed to be a general purpose programming language, with clearly defined behavior,
		and a clean syntax.  Rho's design philosophy is to minimize overall complexity while also
		staying rooted in the reality of programming computers.
	</p>
	<p>
		This document is intended to specify the entire Rho programming language &ndash; not
		necessarily to teach how to program in Rho.  For more friendly documentation, please visit the
		Rho website at: <a href="http://rholang.org">RhoLang.org</a>.
	</p>
	<p>
		The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
		"RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in
		<a href="http://www.ietf.org/rfc/rfc2119.txt" target="_blank">RFC2119</a>.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="license"></a>License
		<a href="#license" title="Link to this section" class="nl">link</a></h3>
	<p>
		<em>(MIT License)</em>
	</p>
	<p>
		Copyright &copy; 2012 Sean Connelly
	</p>
	<p>
		Permission is hereby granted, free of charge, to any person obtaining a copy of this software
		and associated documentation files (the "Software"), to deal in the Software without
		restriction, including without limitation the rights to use, copy, modify, merge, publish,
		distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
		Software is furnished to do so, subject to the following conditions:
	</p>
	<p>
		The above copyright notice and this permission notice shall be included in all copies or
		substantial portions of the Software.
	</p>
	<p>
		THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
		BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
		NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
		DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
		OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="conventions"></a>Document Conventions
		<a href="#conventions" title="Link to this section" class="nl">link</a></h3>
	<p>
		The following styling conventions are used in this document:
	</p>
	<table cellspacing="0"><thead>
		<tr><th>Convention</th><th>Description</th></tr>
	</thead><tbody>
		<tr><td><code>Code</code></td><td>Code elements; generally, something a programmer would type</td></tr>
		<tr><td><code><em>[Replace]</em></code></td><td>Portion of a code element that would be replaced by something else</td></tr>
		<tr><td><a href="#top">Internal link</a></td><td>Internal link that will scroll the page</td></tr>
		<tr><td><a href="http://rholang.org" target="_blank">External link</a></td><td>External link that will pop-out a new window</td></tr>
		<tr><td><a href="#charcl" class="cc">Character class</a></td><td>Defined class of characters, linked to definition</td></tr>
	</tbody></table>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="releases"></a>Release Structure
		<a href="#releases" title="Link to this section" class="nl">link</a></h3>
	<p>
		This document is the final authority on what constitutes "valid Rho".  Implementations of Rho
		contain no authority, and may or may not implement everything this specification defines.
	</p>
	<p>
		Each release of this document will contain a version.  Implementors should advertise what
		version(s) they are targetting with their implementation.
	</p>
	<h4>Verion Scheme</h4>
	<p>
		The version number of the specification has the following format:
	</p>
	<p>
		<code>v<em>[Major]</em>.<em>[Minor]</em>.<em>[Bugfix]</em><em>[Flags]</em></code>
	</p>
	<p>
		The Major version is only increased when a change is made that is no longer backwards
		compatible.
	</p>
	<p>
		The Minor version is only increased when a change is made that is additive in nature &ndash;
		i.e., something that strictly <em>adds</em> a new feature, but does not break backwards
		compatibility.
	</p>
	<p>
		The Bugfix number is only increased when fixing a bug in the specification.  This can mean
		providing additional specification to something that wasn't clearly defined, or fixing
		something that was mistyped.
	</p>
	<p>
		The Flags are only used for tentative releases for developers; <code>a1</code> for
		the first alpha, <code>b3</code> for the third beta release, etc.  The flags allow for
		developers to talk definitively about a potential release.
	</p>
	<p>
		Major and Minor will always exist, but Bugfix will not if it is <code>0</code>.  Flags are
		optional, i.e., <code>v1.0</code>, <code>v1.1</code>, <code>v1.2</code>, <code>v1.2.1</code>,
		<code>v1.2.2</code>, <code>v1.2.2a1</code>, <code>v2.0a1</code>, <code>v2.0a2</code>,
		<code>v2.0rc1</code>, <code>v2.0</code>, etc.
	</p>
	<h4>Versioning Goals</h4>
	<p>
		The ultimate goal of versioning for Rho is to communicate to end-users (programmers) what they
		can expect in terms of backwards compatibility.
	</p>
	<p>
		An increase in Major version communicates that they cannot take anything for granted, and the
		entire structure of the language may have changed.
	</p>
	<p>
		An increase in Minor version communicates that nothing will break, since it only provides them
		with <em>additional</em> features.  All they need to do to gain access to new features is
		increase the Minor version specified in their <a href="#versiontag">Version Tag</a>.
	</p>
	<p>
		This also simplifies life for implementors &ndash; supporting <code>v1.3</code> means they
		can also run <code>v1.2</code>, <code>v1.1</code>, and <code>v1.0</code> code using the same
		implementation (with some checks to make sure users aren't attempting to use features created
		in versions newer than their specified <a href="#verstiontag">Version Tag</a>).
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h2><a name="source"></a>Source File Format
		<a href="#source" title="Link to this section" class="nl">link</a></h2>
	<p>
		Rho source files are <a href="http://en.wikipedia.org/wiki/UTF-8" target="_blank">UTF-8</a>
		encoded text files.
	</p>
	<p>
		For this document, one "character" is synonymous with one unicode code point (<em>not</em> one
		byte).  Character values may be written in Unicode format (U+0020), or hex (0x20) &ndash;
		these are considered equivalent, and always represent one unicode code point.
	</p>
	<p>
		<a href="http://en.wikipedia.org/wiki/Unicode_equivalence" target="_blank">Unicode
		normalization</a> is <em>not</em> performed on the source &ndash; the sequence of code points
		is processed <em>as is</em>.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="whitespace"></a>Whitespace
		<a href="#whitespace" title="Link to this section" class="nl">link</a></h3>
	<p>
		Rho defines two classes of whitespace characters.  At the time of writing, these classes are
		identical.
	</p>
	<p>
		<a name="uwhitespace" href="#uwhitespace" class="cc">uWhitespace</a> characters are defined to
		always match the latest Unicode standard for the
		<a href="http://en.wikipedia.org/wiki/Whitespace_character#Unicode" target="_blank">WSpace=Y
		property</a>.
	</p>
	<p>
		<a name="cwhitespace" href="#cwhitespace" class="cc">cWhitespace</a> characters are strictly,
		and <em>permanently</em>, defined as:
	</p>
	<table cellspacing="0" class="tblClear"><tbody>
		<tr>
			<td>
				<table cellspacing="0"><thead>
					<tr><th>Code Point</th><th>Description</th></tr>
				</thead><tbody>
					<tr><td>U+0009</td><td>Horizontal Tab</td></tr>
					<tr><td>U+000A</td><td>Line feed</td></tr>
					<tr><td>U+000B</td><td>Vertical Tab</td></tr>
					<tr><td>U+000C</td><td>Form feed</td></tr>
					<tr><td>U+000D</td><td>Carriage return</td></tr>
					<tr><td>U+0020</td><td>Space</td></tr>
					<tr><td>U+0085</td><td>Next line</td></tr>
					<tr><td>U+00A0</td><td>No-break space</td></tr>
					<tr><td>U+1680</td><td>Ogham space mark</td></tr>
					<tr><td>U+180E</td><td>Mongolian vowel separator</td></tr>
					<tr><td>U+2000</td><td>En quad</td></tr>
					<tr><td>U+2001</td><td>Em quad</td></tr>
					<tr><td>U+2002</td><td>En space</td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><thead>
					<tr><th>Code Point</th><th>Description</th></tr>
				</thead><tbody>
					<tr><td>U+2003</td><td>Em space</td></tr>
					<tr><td>U+2004</td><td>Three-per-em space</td></tr>
					<tr><td>U+2005</td><td>Four-per-em space</td></tr>
					<tr><td>U+2006</td><td>Six-per-em space</td></tr>
					<tr><td>U+2007</td><td>Figure space</td></tr>
					<tr><td>U+2008</td><td>Punctuation space</td></tr>
					<tr><td>U+2009</td><td>Thin space</td></tr>
					<tr><td>U+200A</td><td>Hair space</td></tr>
					<tr><td>U+2028</td><td>Line separator</td></tr>
					<tr><td>U+2029</td><td>Paragraph separator</td></tr>
					<tr><td>U+202F</td><td>Narrow no-break space</td></tr>
					<tr><td>U+205F</td><td>Medium mathematical space</td></tr>
					<tr><td>U+3000</td><td>Ideographic space</td></tr>
				</tbody></table>
			</td>
		</tr>
	</tbody></table>
	<p>
		If the Unicode standard changes the definition of what is considered whitespace, the
		<a href="#uwhitespace" class="cc">uWhitespace</a> will track the changes &ndash;
		<a href="#cwhitespace" class="cc">cWhitespace</a> will not.  This is to guarantee backwards
		compatibility.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="versiontag"></a>Version Tag
		<a href="#versiontag" title="Link to this section" class="nl">link</a></h3>
	<p>
		All Rho files MUST contain a <em>Version Tag</em>.  The Version Tag identifies where the Rho
		source code begins, and how to process the rest of the source file.
	</p>
	<p>
		All characters before the Version Tag are ignored.
	</p>
	<p>
		The Version Tag is identified by the <em>version prefix</em>, which are the four characters
		<code>rho:</code> (0x72, 0x68, 0x6F, 0x3A).
	</p>
	<p>
		The <em>version string</em> begins immediately after the version prefix, and ends immediately
		before the next <a href="#cwhitespace" class="cc">cWhitespace</a> character, or End-of-File.
	</p>
	<p>
		If an End-of-File is found terminating the version string, the version string must still be
		validated, but the script would be considered empty.
	</p>
	<p>
		Each release of the Rho specification has a list of valid version strings, and what
		components apply to each string.  An invalid version string means the file is invalid and
		MUST be rejected with an error.
	</p>
	<h4>Version String Mapping</h4>
	<p>
		The following version strings are valid for this release of Rho, and map to the appropriate
		sections:
	</p>
	<table cellspacing="0"><thead>
		<tr><th>Version String</th><th>Code Points</th><th>Components</th></tr>
	</thead><tbody>
		<tr><td><code>v1.0</code></td><td>0x76, 0x31, 0x2E, 0x30</td><td>Entire specification</td></tr>
	</tbody></table>
	<h4>Example</h4>
	<p>
		The Version Tag <code>rho:v1.0</code> is made up of the version prefix <code>rho:</code> and
		the version string <code>v1.0</code>.
	</p>
	<svg width="314" height="202" xmlns="http://www.w3.org/2000/svg">
		<rect height="194" width="306" y="4" x="6" stroke-width="3" stroke="#666" fill="#7f7"/>
		<rect height="117" width="144" y="18" x="156" stroke-width="3" stroke="#666" fill="#7ff"/>
		<rect height="117" width="137" y="18" x="19" stroke-width="3" stroke="#666" fill="#ff7"/>
		<text font-weight="bold" transform="matrix(2.30277, 0, 0, 2.20322, -8.39424, -3.21136)" text-anchor="middle" font-family="Monospace" font-size="24" y="31" x="74" stroke-width="0" stroke="#000" fill="#000">rho:v1.0</text>
		<text text-anchor="middle" font-family="Monospace" font-size="24" y="96" x="84" stroke-width="0" stroke="#000" fill="#000">version</text>
		<text text-anchor="middle" font-family="Monospace" font-size="24" y="117" x="84" stroke-width="0" stroke="#000" fill="#000">prefix</text>
		<text text-anchor="middle" font-family="Monospace" font-size="24" y="96" x="223" stroke-width="0" stroke="#000" fill="#000">version</text>
		<text text-anchor="middle" font-family="Monospace" font-size="24" y="117" x="223" stroke-width="0" stroke="#000" fill="#000">string</text>
		<text text-anchor="middle" font-family="Monospace" font-size="24" y="161" x="153" stroke-width="0" stroke="#000" fill="#000">Version</text>
		<text text-anchor="middle" font-family="Monospace" font-size="24" y="182" x="153" stroke-width="0" stroke="#000" fill="#000">Tag</text>
	</svg>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h2><a name="lexer"></a>Lexical Analysis
		<a href="#lexer" title="Link to this section" class="nl">link</a></h2>
	<p>
		Lexical analysis begins after the <a href="#versiontag">Version Tag</a> ends,
		immediately after the <a href="#cwhitespace" class="cc">cWhitespace</a> character that
		terminates the version string.
	</p>
	<p>
		Generally speaking, tokens are greedily matched, and
		<a href="#uwhitespace" class="cc">uWhitespace</a> (or End-of-File) is used to terminate the
		token contents.  For example, <code>~==</code> is tokenized as <code>~=</code> and
		<code>=</code> (not <code>~</code> and <code>==</code>).  <code>~==</code> is invalid in Rho,
		but the lexical analysis phase is only responsibile for tokenizing &ndash; not for validating
		semantics.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="charcl"></a>Character Classes
		<a href="#charcl" title="Link to this section" class="nl">link</a></h3>
	<p>
		A character class is a specific group of characters.  The following classes are referenced
		throughout this document:
	</p>
	<table cellspacing="0"><thead>
		<tr><th>Character Class</th><th>Definition</th></tr>
	</thead><tbody>
		<tr><td><a href="#uwhitespace" class="cc">uWhitespace</a></td>
			<td><a href="http://en.wikipedia.org/wiki/Whitespace_character#Unicode" target="_blank">Unicode WSpace=Y property</a></td></tr>
		<tr><td><a href="#cwhitespace" class="cc">cWhitespace</a></td>
			<td><a href="#cwhitespace">Defined earlier</a></td></tr>
		<tr><td><a name="digit" href="#digit" class="cc">Digit</a></td>
			<td><code>0</code> to <code>9</code> (0x30 to 0x39)</td></tr>
		<tr><td><a name="newline" href="#newline" class="cc">Newline</a></td>
			<td><code>\r\n</code> (0x0D, 0x0A, greedy), or <code>\n</code> (0x0A), or <code>\r</code> (0x0D)</td></tr>
		<tr><td><a name="hex" href="#hex" class="cc">Hex</a></td>
			<td><a href="#digit" class="cc">Digit</a>, or <code>a</code> to <code>f</code> (0x61 to 0x66), or <code>A</code> to <code>F</code> (0x41 to 0x46)</td></tr>
		<tr><td><a name="oct" href="#oct" class="cc">Oct</a></td>
			<td><code>0</code> to <code>7</code> (0x30 to 0x37)</td></tr>
		<tr><td><a name="bin" href="#bin" class="cc">Bin</a></td>
			<td><code>0</code> or <code>1</code> (0x30 or 0x31)</td></tr>
		<tr><td><a name="alpha" href="#alpha" class="cc">Alpha</a></td>
			<td><code>a</code> to <code>z</code> (0x61 to 0x7A), or <code>A</code> to <code>Z</code> (0x41 to 0x5A)</td></tr>
		<tr><td><a name="letter" href="#letter" class="cc">Letter</a></td>
			<td><a href="#alpha" class="cc">Alpha</a>, or <a href="http://en.wikipedia.org/wiki/Character_property_%28Unicode%29#General_Category" target="_blank">Unicode Letter General Category</a> (Lu, Ll, etc...)</td></tr>
		<tr><td><a name="charword" href="#charword" class="cc">Charword</a></td>
			<td><a href="#letter" class="cc">Letter</a>, Underscore <code>_</code> (0x5F), or <code>$</code> (0x24)</td></tr>
		<tr><td><a name="word" href="#word" class="cc">Word</a></td>
			<td><a href="#charword" class="cc">Charword</a> or <a href="#digit" class="cc">Digit</a></td></tr>
		<tr><td><a name="numbody" href="#numbody" class="cc">NumBody</a></td>
			<td><a href="#word" class="cc">Word</a>, or <code>.</code> (0x2E)</td></tr>
	</tbody></table>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="keydents"></a>Keydentifiers
		<a href="#keydents" title="Link to this section" class="nl">link</a></h3>
	<p>
		Keydentifiers are defined as a series of characters, starting with a
		<a href="#charword" class="cc">Charword</a>, followed by zero or more
		<a href="#word" class="cc">Word</a> characters (greedy).
	</p>
	<p>
		After read in completely, a keydentifier can be categorized as a
		<a href="#keywords">Keyword</a>, an <a href="#idents">Identifier</a>, or rejected in error.
	</p>
	<p>
		If the keydentifier is on the list of <a href="#keywords">keywords</a>, it is promoted to a
		Keyword token.
	</p>
	<p>
		Otherwise, it is validated against the <a href="#idents">requirements of an identifier</a>,
		and if valid, promoted to an Identifier token.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="keywords"></a>Keywords
		<a href="#keywords" title="Link to this section" class="nl">link</a></h3>
	<p>
		Rho defines the following keywords:
	</p>
	<table cellspacing="0" class="tblClearMerge"><thead>
		<tr><th colspan="4">Keywords</th></tr>
	</thead><tbody>
		<tr>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>and</code></td></tr>
					<tr><td><code>as</code></td></tr>
					<tr><td><code>bounce</code></td></tr>
					<tr><td><code>catch</code></td></tr>
					<tr><td><code>carry</code></td></tr>
					<tr><td><code>case</code></td></tr>
					<tr><td><code>define</code></td></tr>
					<tr><td><code>depart</code></td></tr>
					<tr><td><code>do</code></td></tr>
					<tr><td><code>elseif</code></td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>else</code></td></tr>
					<tr><td><code>end</code></td></tr>
					<tr><td><code>eval</code></td></tr>
					<tr><td><code>exit</code></td></tr>
					<tr><td><code>goto</code></td></tr>
					<tr><td><code>if</code></td></tr>
					<tr><td><code>import</code></td></tr>
					<tr><td><code>is</code></td></tr>
					<tr><td><code>likely</code></td></tr>
					<tr><td><code>metatypein</code></td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>metatypeof</code></td></tr>
					<tr><td><code>monitorof</code></td></tr>
					<tr><td><code>my</code></td></tr>
					<tr><td><code>next</code></td></tr>
					<tr><td><code>or</code></td></tr>
					<tr><td><code>override</code></td></tr>
					<tr><td><code>pointerof</code></td></tr>
					<tr><td><code>return</code></td></tr>
					<tr><td><code>super</code></td></tr>
					<tr><td><code>switch</code></td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>syscall</code></td></tr>
					<tr><td><code>then</code></td></tr>
					<tr><td><code>throw</code></td></tr>
					<tr><td><code>try</code></td></tr>
					<tr><td><code>typein</code></td></tr>
					<tr><td><code>typeof</code></td></tr>
					<tr><td><code>unlikely</code></td></tr>
					<tr><td><code>when</code></td></tr>
					<tr><td><code>while</code></td></tr>
					<tr><td><code style="visibility: hidden;">&nbsp;</code></td></tr>
				</tbody></table>
			</td>
		</tr>
	</tbody></table>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="idents"></a>Identifiers
		<a href="#idents" title="Link to this section" class="nl">link</a></h3>
	<p>
		Identifiers can only be created by <a href="#keydents">Keydentifiers</a>, and therefore are
		restricted by their rules.  In addition to the limitations of keydentifiers, an identifier
		cannot be larger than 50 characters.  Keydentifiers larger than 50 characters MUST be rejected
		in error.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="specials"></a>Special Sequences
		<a href="#specials" title="Link to this section" class="nl">link</a></h3>
	<p>
		Rho defines the following special sequences:
	</p>
	<table cellspacing="0" class="tblClearMerge"><thead>
		<tr><th colspan="6">Specials</th></tr>
	</thead><tbody>
		<tr>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>~</code> (0x7E)</td></tr>
					<tr><td><code>!</code> (0x21)</td></tr>
					<tr><td><code>%</code> (0x25)</td></tr>
					<tr><td><code>^</code> (0x5E)</td></tr>
					<tr><td><code>*</code> (0x2A)</td></tr>
					<tr><td><code>-</code> (0x2D)</td></tr>
					<tr><td><code>+</code> (0x2B)</td></tr>
					<tr><td><code>=</code> (0x3D)</td></tr>
					<tr><td><code>:</code> (0x3A)</td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>&lt;</code> (0x3C)</td></tr>
					<tr><td><code>,</code> (0x2C)</td></tr>
					<tr><td><code>&gt;</code> (0x3E)</td></tr>
					<tr><td><code>/</code> (0x2F)</td></tr>
					<tr><td><code>[</code> (0x5B)</td></tr>
					<tr><td><code>]</code> (0x5D)</td></tr>
					<tr><td><code>{</code> (0x7B)</td></tr>
					<tr><td><code>}</code> (0x7D)</td></tr>
					<tr><td><code>@</code> (0x40)</td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>&amp;</code> (0x26)</td></tr>
					<tr><td><code>(</code> (0x28)</td></tr>
					<tr><td><code>)</code> (0x29)</td></tr>
					<tr><td><code>|</code> (0x7C)</td></tr>
					<tr><td><code>.</code> (0x2E)</td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>~=</code> (0x7E, 0x3D)</td></tr>
					<tr><td><code>!=</code> (0x21, 0x3D)</td></tr>
					<tr><td><code>%=</code> (0x25, 0x3D)</td></tr>
					<tr><td><code>^=</code> (0x5E, 0x3D)</td></tr>
					<tr><td><code>*=</code> (0x2A, 0x3D)</td></tr>
					<tr><td><code>-=</code> (0x2D, 0x3D)</td></tr>
					<tr><td><code>+=</code> (0x2B, 0x3D)</td></tr>
					<tr><td><code>==</code> (0x3D, 0x3D)</td></tr>
					<tr><td><code>?:</code> (0x3F, 0x3A)</td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>&lt;=</code> (0x3C, 0x3D)</td></tr>
					<tr><td><code>=&gt;</code> (0x3D, 0x3E)</td></tr>
					<tr><td><code>&gt;=</code> (0x3E, 0x3D)</td></tr>
					<tr><td><code>/=</code> (0x2F, 0x3D)</td></tr>
					<tr><td><code>#[</code> (0x23, 0x5B)</td></tr>
					<tr><td><code>?[</code> (0x3F, 0x5B)</td></tr>
					<tr><td><code>??</code> (0x3F, 0x3F)</td></tr>
					<tr><td><code>&gt;&gt;</code> (0x3E, 0x3E)</td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
				</tbody></table>
			</td>
			<td>
				<table cellspacing="0"><tbody>
					<tr><td><code>...</code> (0x2E, 0x2E, 0x2E)</td></tr>
					<tr><td><code>??=</code> (0x3F, 0x3F, 0x3D)</td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
					<tr><td><span style="visibility: hidden;"><code>&nbsp;</code>&nbsp;</span></td></tr>
				</tbody></table>
			</td>
		</tr>
	</tbody></table>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="numbers"></a>Numbers
		<a href="#numbers" title="Link to this section" class="nl">link</a></h3>
	<p>
		Numbers are defined as a series of characters, starting with a
		<a href="#digit" class="cc">Digit</a>, followed by zero or more
		<a href="#numbody" class="cc">NumBody</a> characters.
	</p>
	<p>
		If the number starts with <code>0x</code> (0x30, 0x78), and the last consumed character was
		a <code>p</code> or <code>P</code> (0x70 or 0x50), then <code>+</code> and <code>-</code>
		(0x2B, 0x2D) are valid characters to be added to the number.
	</p>
	<p>
		Likewise, if the number does not start with <code>0x</code>, and the last consumed character
		was a <code>e</code> or <code>E</code> (0x65 or 0x45), then <code>+</code> and <code>-</code>
		(0x2B, 0x2D) are valid characters to be added to the number.
	</p>
	<p>
		This means the following are valid numbers, according to lexical analysis:
		<code>1hello</code>, <code>0....</code>, <code>0xTOP+more</code>,
		<code>0000abcde-fghij</code>.
	</p>
	<p>
		After a number has been identified (greedily), it is validated against the requirements for
		a <a href="#ratiolit">Ratio Literal</a>.  If it meets the requirements, it is promoted to a
		token.  Otherwise, the source MUST be rejected with error.
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="ratiolit"></a>Ratio Literal
		<a href="#ratiolit" title="Link to this section" class="nl">link</a></h3>
	<p>
		Ratio Literals can only be created by <a href="#numbers">Numbers</a>, and therefore are
		restricted by their rules.
	</p>
	<p>
		If the Number ends in a <code>j</code> (0x6A), the Ratio Literal is flagged as imaginary, and
		processing continues ignoring the <code>j</code>.
	</p>
	<p>
		If the remaining Number matches the format of <code>0<em>[zero or more
		underscores]</em>NaN<em>[zero or more underscores]</em></code> (0x30, zero or more 0x5F, 0x4E,
		0x61, 0x4E, zero or more 0x5F), it is identified as a Not-a-Number constant (with the optional
		imaginary flag).
	</p>
	<p>
		If the remaining Number matches the format of <code>0<em>[zero or more
		underscores]</em>inf<em>[zero or more underscores]</em></code> (0x30, zero or more 0x5F, 0x69,
		0x6E, 0x66, zero or more 0x5F), it is identified as an Infinite constant (with the optional
		imaginary flag).
	</p>
	<p>
		Otherwise, the remaining Number must be ... MYTODO
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<h3><a name="stringfmt"></a>String Formats
		<a href="#stringfmt" title="Link to this section" class="nl">link</a></h3>
	<p>
		The term "string" has different meanings, depending on what Rho component is being discussed.
		For lexical analysis, a "string" is something that begins and ends with a special sequence of
		characters, has interpolation, and escape sequences.
	</p>
	<h4>String Interpolation</h4>
	<p>
		String interpolation, at the lexical analysis phase, simply means that the lexer continues
		generating tokens normally, even though it is inside a string.  This means that the lexer's
		string engine must stack (as you can have strings inside of strings inside of strings, etc).
	</p>
	<p>
		As an example: <code>"hello, %{first ~ "_" ~ last} :-)"</code>
	</p>
	<p>
		The lexer should generate tokens:
	</p>
	<ol>
		<li>Begin Unicode String</li>
		<li style="padding-left: 2em;">Unicode Literal <code>hello,&nbsp;</code></li>
		<li style="padding-left: 2em;">Begin Inner Expression</li>
		<li style="padding-left: 4em;">Identifier <code>first</code></li>
		<li style="padding-left: 4em;">Special <code>~</code></li>
		<li style="padding-left: 4em;">Begin Unicode String</li>
		<li style="padding-left: 6em;">Unicode Literal <code>_</code></li>
		<li style="padding-left: 4em;">End Unicode String</li>
		<li style="padding-left: 4em;">Special <code>~</code></li>
		<li style="padding-left: 4em;">Identifier <code>last</code></li>
		<li style="padding-left: 2em;">End Inner Expression</li>
		<li style="padding-left: 2em;">Unicode Literal <code>&nbsp;:-)</code></li>
		<li>End Unicode String</li>
	</ol>
	<p>
		The above list contains additional spacing to indicate the stacking nature of the tokens, but
		this stacking nature does not need to be part of the tokens themselves, and can be maintained
		by the lexer.
	</p>

	<h4>Byte String</h4>
	<p>
		A byte string begins with a single quote <code>'</code> (0x27), and ends with a non-escaped
		single quote <code>'</code>.  If a <a href="#newline" class="cc">Newline</a> is found before
		the end of the string, the string is considered terminated immediately after the
		<a href="#newline" class="cc">Newline</a>, and an error MUST be generated.
	</p>
	<p>
		Unicode characters found within the string in the range U+0000 to U+00FF are not altered in
		any way.  Characters found outside this range MUST generate an error.
	</p>
	<p>
		Escape sequences begin with <code>\</code> (0x5C).  The following escape sequences are valid:
	</p>
	<table cellspacing="0"><thead>
		<tr><th>Escape Sequence</th><th>Description</th></tr>
	</thead><tbody>
		<tr><td><code>\0</code> (0x5C, 0x30)</td><td>Null character (0x00)</td></tr>
		<tr><td><code>\t</code> (0x5C, 0x74)</td><td>Horizontal tab (0x09)</td></tr>
		<tr><td><code>\n</code> (0x5C, 0x6E)</td><td>Line feed (0x0A)</td></tr>
		<tr><td><code>\r</code> (0x5C, 0x72)</td><td>Carriage return (0x0D)</td></tr>
		<tr><td><code>\'</code> (0x5C, 0x27)</td><td>Single quote (0x27)</td></tr>
		<tr><td><code>\\</code> (0x5C, 0x5C)</td><td>Backslash (0x5C)</td></tr>
		<tr><td><code>\x<em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em></code> (0x5C, 0x78, ...)</td>
			<td>Character mapped to the code point U+00XX</td></tr>
	</tbody></table>
	<p>
		(Note: <code>\"</code> is invalid inside a Byte String)
	</p>
	<p>
		MYTODO: interpolation with <code>%{</code>
	</p>
	<p>
		MYTODO: escape? <code>%{%}</code>
	</p>
	<h4>Unicode String</h4>
	<p>
		A unicode string begins with a double quote <code>"</code> (0x22), and ends with a non-escaped
		double quote <code>"</code>.  If a <a href="#newline" class="cc">Newline</a> is found before
		the end of the string, the string is considered terminated immediately after the
		<a href="#newline" class="cc">Newline</a>, and an error MUST be generated.
	</p>
	<p>
		Unicode characters found within the string are not altered or restricted in any way.
	</p>
	<p>
		Escape sequences begin with <code>\</code> (0x5C).  The following escape sequences are valid:
	</p>
	<table cellspacing="0"><thead>
		<tr><th>Escape Sequence</th><th>Description</th></tr>
	</thead><tbody>
		<tr><td><code>\0</code> (0x5C, 0x30)</td><td>Null character (0x00)</td></tr>
		<tr><td><code>\t</code> (0x5C, 0x74)</td><td>Horizontal tab (0x09)</td></tr>
		<tr><td><code>\n</code> (0x5C, 0x6E)</td><td>Line feed (0x0A)</td></tr>
		<tr><td><code>\r</code> (0x5C, 0x72)</td><td>Carriage return (0x0D)</td></tr>
		<tr><td><code>\"</code> (0x5C, 0x22)</td><td>Double quote (0x22)</td></tr>
		<tr><td><code>\\</code> (0x5C, 0x5C)</td><td>Backslash (0x5C)</td></tr>
		<tr><td><code>\x<em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em></code> (0x5C, 0x78, ...)</td>
			<td>Character mapped to the code point U+00XX</td></tr>
		<tr><td><code>\u<em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em></code> (0x5C, 0x75, ...)</td>
			<td>Character mapped to the code point U+XXXX</td></tr>
		<tr><td><code>\U<em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em><em>[<a href="#hex" class="cc">Hex</a>]</em></code> (0x5C, 0x55, ...)</td>
			<td>Character mapped to the code point U+XXXXXX</td></tr>
	</tbody></table>
	<p>
		(Note: <code>\'</code> is invalid inside a Unicode String)
	</p>
	<p>
		MYTODO: interpolation with <code>%{</code>
	</p>
	<p>
		MYTODO: escape? <code>%{%}</code>
	</p>
	<h4>End-of-Line String</h4>
	<p>
		End-of-line strings begin with <code>&lt;&lt;</code> (0x3C, 0x3C), and ends after at the next
		<a href="#newline" class="cc">Newline</a>.  If no <a href="#newline" class="cc">Newline</a> is
		found before the End-of-File, an error MUST be generated.
	</p>
	<p>
		MYTODO: interpolation with <code>^{</code>
	</p>
	<p>
		MYTODO: escape sequence <code>^{^}</code>
	</p>
	<h4>Macro String</h4>
	<p>
		Macro strings begin with <code>#{</code> (0x23, 0x7B).  A macro string continues consuming
		characters, keeping a count of <code>{</code> (0x7B) and <code>}</code> (0x7D).  A macro
		string terminates when the matching <code>}</code> is found for the start of string.
	</p>
	<p>
		MYTODO: interpolation with <code>#{</code>
	</p>
	<p>
		MYTODO: escape sequence <code>#{#}</code>
	</p>
	<p class="toplink"><a href="#top">top &uarr;</a></p>

	<p>
		MYTODO: add <code>0d1234123412341234</code> for doubles, <code>0s12341234</code> for singles.
	</p>

	<p>
		MYTODO: figure out what expressions are allowed to have commas... <code> goto x, y</code>???
	</p>

	<p>
		MYTODO: require all <code>import</code>s to define an <code>as</code>? (no... I don't think
		so...)
	</p>

	<p>
		MYTODO: make sure <code>say &lt;&lt; blah</code> converts to <code>say("blah\n")</code> (with
		newline!), so <code>&lt;&lt;</code> can chain (i.e., <code>say &lt;&lt; say &lt;&lt;
		blah</code>)
	</p>

	<p>
		MYTODO: can <code>as</code> contain an <code>else</code>?
	</p>

	<p>
		MYTODO: does <code>bitX</code> need to be a power of 2?  I don't think so...
	</p>

	<p>
		MYTODO: <code>define something symbol(two, three) one end</code> (defaults to one, or two if
		one doesn't exist) -- can you <code>define something symbol(enumType) end</code>? or vice-versa?
	</p>

	<p>
		MYTODO: <code>define var union_all() end</code>
	</p>

	<p>
		patterned type: <code>define unionN#[A, B, C, ... N] union(A, B, C, ... N) end</code>
	</p>
</div>
<div id="footer">
	Visit Rho on the Web at: <a href="http://rholang.org">RhoLang.org &raquo;</a>
</div>
</body>
</html>
